﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Demo.Framework.GameObjects
{
    class WindMill
    {
        private float _angle;
        private ModelManager _modelManager;

        public float SpeedRotation { get; set; }

        public WindMill(ModelManager md, Vector3 position)
        {
            _modelManager = md;

            _modelManager.AddModel("meln1", "Models//scene1_meln1");
            _modelManager.AddModel("meln2", "Models//scene1_meln2");
            _modelManager.AddModel("meln3", "Models//scene1_meln3");
            _modelManager.AddModel("meln4", "Models//scene1_meln4");

            _modelManager.GetModel("meln1").SetPosition(new Vector3(position.X, position.Y - 10, position.Z), Matrix.Identity);
            _modelManager.GetModel("meln2").SetPosition(new Vector3(position.X, position.Y, position.Z), Matrix.Identity);
            _modelManager.GetModel("meln3").SetPosition(new Vector3(position.X-250, position.Y - 50, position.Z-200), Matrix.Identity);
            _modelManager.GetModel("meln4").SetPosition(new Vector3(position.X, position.Y + 890, position.Z-100), Matrix.Identity);

            _angle = 0;
            SpeedRotation = 0.002f;
        }

        
        public void Update()
        {
            _angle -= SpeedRotation;

            if (_angle<=-360)
            {
                _angle = 0;
            }

            _modelManager.GetModel("meln4").Rotation(Matrix.CreateRotationZ(_angle));
        }
    }
}
